package com.ln.controller;

import com.ln.entity.Dept;
import com.ln.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/12/7 15:29
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/{deptno}")
    public Dept getById(@PathVariable int deptno){
        return deptService.findById(deptno);
    }

    @PostMapping
    public Dept save(@RequestBody Dept dept){
        return deptService.save(dept);
    }
    @DeleteMapping("/{deptno}")
    public int delete(@PathVariable int deptno){
        return deptService.delete(deptno);
    }
    @PutMapping
    public Dept update(@RequestBody Dept dept){
        return deptService.update(dept);
    }
}
